class Solution {
    public int missingNumber1(int[] nums) {
        int sum = 0;
        for (int i = 0; i < nums.length + 1; i++) {
            sum += i;
        }
        int ret = 0;
        for (int i = 0; i < nums.length; i++) {
            ret += nums[i];
        }
        return sum - ret;
    }
    public int missingNumber2(int[] nums) {
        int a = 0;
        for (int i = 0; i < nums.length; i++) {
            a ^= i;
        }
        for (int i = 0; i < nums.length; i++) {
            a ^= nums[i];
        }
        return a;
    }
}